package com.hntest.service.impl;

import com.hntest.dao.AdminDao;
import com.hntest.entity.Admin;
import com.hntest.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("adminService")
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDao adminDao;

    public void setAdminDao(AdminDao adminDao) {
        this.adminDao = adminDao;
    }

    @Override
    public Admin login(Admin admin) {
        System.out.println("开始业务逻辑层的调用（登录）....");
        return adminDao.login(admin);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
    public boolean register(Admin admin) {
        System.out.println("开始业务逻辑层的调用（注册）....");
        System.out.println(admin);
        int n=adminDao.insertAdmin(admin);

        //n=adminDao.insertAdmin(admin);
        if(n>0) {
            return true;
        }else {
            return false;
        }
    }
}
